package com.baizhi.controller;

import com.baizhi.service.LogService;
import com.baizhi.vo.LogBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/v2")
@Api(value = "TestController", description = "测试控制器")
@Slf4j
public class TestController {


    @Resource
    private LogService logService;

    @Resource
    private HttpServletRequest request;


    @ApiOperation(tags = "apiTag1", value = "控制器方法1")
    @GetMapping("/1")
    public HttpStatus tInter(@RequestParam(required = false) String name) {

        return HttpStatus.OK;
    }

    @ApiOperation(tags = "getLogs", value = "获取日志")
    @GetMapping("/2")
    public Page getLogs(@RequestParam(required = false) Map<String, String> map) {

        PageImpl<LogBean> page = logService.getLogs(map);
        return page;
    }

    @ApiOperation(tags = "testContent", value = "获取http内容")
    @GetMapping("/3")
    public HttpStatus testContent() {

        return HttpStatus.OK;
    }
}
